The idea here is to first save your output into a file and then send the file as an attachment into your email. We illustrate this process using an example.
1. This example first creates a data set called sendmail and then prints the content of the data set into the output.
/*Create an example*/
data sendmail;
input test;
cards;
1
2
3
5
;
run;proc print data=sendmail;
run;
2. The output is then saved into a file called test.out using the codes like
/*Save the output and the log into files*/
DM OUTPUT 'FILE "c:\send\test.OUT"';
DM LOG 'FILE "c:\send\test.LOG"';
3. Finally, we send this output file as attachment to your email using the codes like
/*Send the output to your email*/
data _null_;
call system('c:\send\mailcmd "mail.xxxx.xxxx" "xxxx@gmail.com" "xxxx@gmail.com" "Subject: SAS results" "Contents: SAS results" "" "c:\send\test.OUT"');
run;
In this step, we used a dos program called mailcmd which can be downloaded by clicking this link http://www.sms4mail.com/download/mailcmd.zip. In my example, I put this dos file in the folder "c:\send".
Run step 1 to 3, you will receive an email with the file test.out as an attachment.